package cn.wanda.bi.sunshine.platform.server.controller.authorize;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.wanda.bi.sunshine.platform.server.aspect.Logging;
import cn.wanda.bi.sunshine.platform.server.controller.response.common.SimpleResponse;
import cn.wanda.bi.sunshine.platform.server.service.authorize.TencentOpenimService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * Created by wangfupeng1
 */
@Api(description = "腾讯im接口")
@RestController
@RequestMapping(value = "/v1/im", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AuthorizeTencentOpenimController implements Logging {

    public static final Logger logger = LoggerFactory.getLogger(AuthorizeTencentOpenimController.class);

    @Autowired
    private TencentOpenimService tencentOpenimService;

    @ApiOperation("单发单聊消息，发消息发给指定的一个人，管理员向账号发消息，接收方看到消息发送者是管理员；，传入参数是用户uid，用户loginToken，appid，发送内容字符串，输出数据是ActionStatus(请求处理的结果，OK表示处理成功，FAIL表示失败。)，ErrorCode(错误码)，ErrorInfo(错误信息)，MsgTime(消息时间戳，unix时间戳。)")
    @RequestMapping(value = "/openim/sendmsg", method = RequestMethod.POST)
    SimpleResponse sendmsg(
    		@ApiParam(value = "用户uid") @RequestParam("uid") String uid,
    		@ApiParam(value = "用户loginToken") @RequestParam("loginToken") String loginToken,
    		@ApiParam(value = "appid") @RequestParam("appid") String appid,
    		@ApiParam(value = "发送内容data") @RequestParam("data") String data
            ) {
    	return tencentOpenimService.sendmsg(uid, loginToken, appid, data);
    }
    
}
